//
//  RankListDataSource.m
//  tcpoctest
//
//  Created by gump on 6/6/13.
//  Copyright (c) 2013 gump. All rights reserved.
//

#import "RankListDataSource.h"

@implementation RankListDataSource

-(id)init
{
    self = [super init];
    
    if (self != nil) {
        richShowArr = [[NSMutableArray alloc] init];
        
        pthread_mutex_init(&mutexRich, 0);
    }
    
    return self;
}

-(void)AddRichInfo:(rankListInfo *)rlinfo
{
    pthread_mutex_lock(&mutexRich);
    
    [richShowArr addObject:rlinfo];
    
    pthread_mutex_unlock(&mutexRich);
}

-(void)delAllArr
{
    pthread_mutex_lock(&mutexRich);
    
    [richShowArr removeAllObjects];
    
    pthread_mutex_unlock(&mutexRich);
}

-(int)ArrCount
{
    int icount = 0;
    
    pthread_mutex_lock(&mutexRich);
    
    icount = richShowArr.count;
    
    pthread_mutex_unlock(&mutexRich);
    
    return icount;
}

-(rankListInfo *)RankListInfoByRow:(int)irow
{
    rankListInfo *rlinfo = nil;
    
    pthread_mutex_lock(&mutexRich);
    
    if (irow >= 0 && irow < richShowArr.count) {
        rlinfo = [richShowArr objectAtIndex:irow];
    }
    
    pthread_mutex_unlock(&mutexRich);
    
    return rlinfo;
}

@end
